package rwt.server.handlers;

import rwt.server.RailServer;
import rwt.server.RailroadMessages.PutSwitchStateMsg;
import rwt.server.WebMessages.PutSwitchState;
import rwt.server.core.*;
import rwt.server.railroad.Switches;

public class PutSwitchStateHandler extends MessageHandler<PutSwitchStateMsg>
{
	@Override
	public void handle(PutSwitchStateMsg message, IConnection source) throws Exception
	{
		RailServer.getSwitchManager().SetSwitch(message.switchId, message.state);
		PutSwitchState webMsg = new PutSwitchState(message.switchId, message.state);
		Switches.getInstance().sendToAll(webMsg);
	}
}
